
import{
    getUserDiscountPage
  } from '@/common/api/user_api.js'

  
export default {
  
  data:()=>{
    return{
      beforePopupCheckinModalCount:0,
      showCouponByDailyCheckin:false,
    }
  },
  
  methods:{
    closeDailyCouponModalHandle(){
      this.showCouponByDailyCheckin = false
    },
    confirmDailyCouponModalHandle(){
      this.showCouponByDailyCheckin = false
      this.couponByDailyCheckinVisible = false
    },
    async countCouponNum(){
      const {data:dRes} = await getUserDiscountPage({
        pageNo: 1,
        pageSize: 1000,
        useStatus:'Y'
      })
      if(dRes.success){
        const { 
          rows = []
        } = dRes.data
        const filteredArray = rows.filter(obj => (obj.usageScenario === 1 ||obj.usageScenario === 0) );
        console.log(filteredArray,'=====filteredArray')
        return filteredArray.length
      }else{
        return 0
      }
    },
    async recordCouponCount(){
      this.beforePopupCheckinModalCount = await this.countCouponNum()
    },
    async closeDailyCheckinModalHandle(){
      const afterCount = await this.countCouponNum()
      if(afterCount > this.beforePopupCheckinModalCount){
        this.showCouponByDailyCheckin = true
      }
    }
  }
}